INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/audio_process)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/audio_process/include)

MACRO(DEFTEST NAME)
	SET(TEST_NAME ${TEST_PREFIX}${NAME})
	SET(${TEST_NAME}_SRCS ${TEST_COMMON_FILES} ${TEST_NAME}.c)

	ADD_EXECUTABLE(${TEST_NAME}-glibc ${${TEST_NAME}_SRCS})
	SET_TARGET_PROPERTIES(${TEST_NAME}-glibc PROPERTIES
		OUTPUT_NAME "${TEST_NAME}"
		RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/audio_test/glibc
		LINK_FLAGS "-ldl"
	)
	ADD_DEPENDENCIES(${TEST_NAME}-glibc ${TEST_DEPLIB}_static_glibc alog_static_glibc)
	TARGET_LINK_LIBRARIES(${TEST_NAME}-glibc
		${PROJECT_BINARY_DIR}/lib-glibc/lib${TEST_DEPLIB}.a
		${PROJECT_BINARY_DIR}/lib-glibc/libalog.a
		pthread m rt stdc++
	)

    ADD_EXECUTABLE(${TEST_NAME}-uclibc ${${TEST_NAME}_SRCS})
	SET_TARGET_PROPERTIES(${TEST_NAME}-uclibc PROPERTIES
		OUTPUT_NAME "${TEST_NAME}"
		RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/audio_test/uclibc
		LINK_FLAGS "-muclibc -ldl"
		COMPILE_FLAGS "-muclibc -ldl"
	)

	ADD_DEPENDENCIES(${TEST_NAME}-uclibc ${TEST_DEPLIB}_static_uclibc alog_static_uclibc)
	TARGET_LINK_LIBRARIES(${TEST_NAME}-uclibc
		${PROJECT_BINARY_DIR}/lib-uclibc/lib${TEST_DEPLIB}.a
		${PROJECT_BINARY_DIR}/lib-uclibc/libalog.a
		pthread m rt stdc++
	)

ENDMACRO()

MACRO(DEFPROCESSTEST NAME)
	 SET(TEST_PROCESS_NAME ${TEST_AUDIO_PROCESS_PREFIX}${NAME})
	 SET(${TEST_PROCESS_NAME}_SRCS ${TEST_AUDIO_PROCESS_FILES} ${TEST_COMMON_FILES} ${TEST_PROCESS_NAME}.c)

	 ADD_EXECUTABLE(${TEST_PROCESS_NAME}-glibc ${${TEST_PROCESS_NAME}_SRCS})
	 SET_TARGET_PROPERTIES(${TEST_PROCESS_NAME}-glibc PROPERTIES
		OUTPUT_NAME "${TEST_PROCESS_NAME}"
	    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/audio_test/glibc
		LINK_FLAGS "-ldl"
	)

	ADD_DEPENDENCIES(${TEST_PROCESS_NAME}-glibc ${TEST_DEPLIB}_static_glibc alog_static_glibc)
	TARGET_LINK_LIBRARIES(${TEST_PROCESS_NAME}-glibc
		${PROJECT_BINARY_DIR}/lib-glibc/lib${TEST_DEPLIB}.a
		${PROJECT_BINARY_DIR}/lib-glibc/lib${TEST_AUDIO_PROCESS_DEFLIB}.so
		${PROJECT_BINARY_DIR}/lib-glibc/libalog.a
		pthread m rt stdc++
	)

	ADD_EXECUTABLE(${TEST_PROCESS_NAME}-uclibc ${${TEST_PROCESS_NAME}_SRCS})
	SET_TARGET_PROPERTIES(${TEST_PROCESS_NAME}-uclibc PROPERTIES
	OUTPUT_NAME "${TEST_PROCESS_NAME}"
	RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/audio_test/uclibc
	LINK_FLAGS "-muclibc -ldl"
	COMPILE_FLAGS "-muclibc -ldl"
	)
	ADD_DEPENDENCIES(${TEST_PROCESS_NAME}-uclibc ${TEST_DEPLIB}_static_uclibc alog_static_uclibc)
    TARGET_LINK_LIBRARIES(${TEST_PROCESS_NAME}-uclibc
		${PROJECT_BINARY_DIR}/lib-uclibc/lib${TEST_DEPLIB}.a
		${PROJECT_BINARY_DIR}/lib-uclibc/lib${TEST_AUDIO_PROCESS_DEFLIB}.so
		${PROJECT_BINARY_DIR}/lib-uclibc/libalog.a
		pthread m rt stdc++
	)

ENDMACRO()

ADD_SUBDIRECTORY(src)

FILE(GLOB_RECURSE INSTALL_FILES doc/*)
INSTALL(FILES ${INSTALL_FILES}
	DESTINATION  ${CMAKE_BINARY_DIR}/bin/audio_test/doc
)
FILE(GLOB_RECURSE INSTALL_FILES data/*)
INSTALL(FILES ${INSTALL_FILES}
	DESTINATION  ${CMAKE_BINARY_DIR}/bin/audio_test/data
)
